package com.slz3.business.module.socialManagement.socArticle.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.slz3.business.frame.enums.AuditFlag;
import com.slz3.business.frame.enums.UsingFlag;
import com.slz3.business.frame.functions.Add;
import com.slz3.business.frame.functions.Modify;
import com.slz3.business.frame.module.DomainEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Length;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.time.LocalDate;
import java.util.UUID;

import static javax.persistence.EnumType.STRING;

@MappedSuperclass
@Data
@EqualsAndHashCode(callSuper = false)
public class SocArticleEntity extends DomainEntity {

    /**
     * 【外键】商品
     */
//    @NotNull(message = "商品 必须非空!", groups = {Add.class, Modify.class})
    private UUID fkGoods;

    /**
     * 主题
     */
    @NotNull(message = "主题 必须非空!", groups = {Add.class, Modify.class})
    @Length(min = 1, max = 80, message = "主题 必须非空并且不超过 80 个字符!", groups = {Add.class, Modify.class})
    private String serTheme;

    /**
     * 描述
     */
    @NotNull(message = "主题 必须非空!", groups = {Add.class, Modify.class})
    @Length(min = 1, max = 200, message = "描述 必须非空并且不超过 200 个字符!", groups = {Add.class, Modify.class})
    private String serDescribe;

    /**
     * 大图 URL
     */
    @NotNull(message = "主题 必须非空!", groups = {Add.class, Modify.class})
    private String serBigImgUrl;

    /**
     * 富文本编辑器内容
     */
    @Basic(fetch = FetchType.LAZY)
    @Column(columnDefinition = "TEXT")
    private String serEditorContent;

    //

    private String serNum;
    private String serMemo;
    @Enumerated(STRING)
    private AuditFlag serAudit;
    @Enumerated(STRING)
    private UsingFlag serUsing;
    private String serLabels;
    private String serFileUrl;
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
    private LocalDate serInputGroupData;

    /**
     * 商品名称
     */
    //@NotNull(message = "商品名称 必须非空!", groups = {Add.class, Modify.class})
//    @Length(min = 1, max = 80, message = "主题 必须非空并且不超过 80 个字符!", groups = {Add.class, Modify.class})
    private String serGoodsName;


}
